package cn.edu.scau.cmi.yangqing.composite_consistency;

import java.util.ArrayList;
import java.util.Iterator;

public class Composite implements WorldOrganization {

	private ArrayList<WorldOrganization> countryList;
	private String greet="";
	
	
	public Composite() {
		countryList = new ArrayList<WorldOrganization>();
	}

	public void add(WorldOrganization country) {
		if(country!=null)
			countryList.add(country);
	}
	public void remove(WorldOrganization country) {
		if(country!=null)
			countryList.remove(country);
	}
	public Iterator<WorldOrganization> elements(){
		return countryList.iterator();
	}
	public int getSize() {
		return countryList.size();
	}
	public String say() {
		int len = countryList.size();
		for(int i=0; i<len; i++) {
			WorldOrganization organization = countryList.get(i);
			//System.out.println(organization.say());
			greet += organization.say()+"\n";
		}
		return greet;
	}

}
